﻿using ProjScan.RecordManager.AssetData;
using ProjScan.ScanRule.Attr;
using UnityEngine;
using UnityEngine.Rendering;

namespace ProjScan.ScanRule.SceneCheck
{
    [ScenesCheckRuleAttr]
    internal class Scene_ShadowResolution : SceneObjRecordRuleImp
    {
        protected override bool IsOK(SceneObjAssetData assetData)
        {
            if (QualitySettings.shadows == ShadowQuality.Disable)
            {
                return true;
            }

            Light[] components = assetData.gameObj.GetComponents<Light>();
            if (components != null)
            {
                Light[] array = components;
                foreach (Light light in array)
                {
                    if (light.shadowResolution != LightShadowResolution.FromQualitySettings && light.shadows != 0 && light.shadowResolution != (LightShadowResolution)QualitySettings.shadowResolution)
                    {
                        return false;
                    }
                }
            }

            return true;
        }
    }
}